﻿using Microsoft.AspNetCore.Mvc;

namespace SystemMiddleWare.Controllers
{
	[Route("Product")]
	public class ProductController : Controller
	{
		[Route("Detail/{id}")]
		public IActionResult Detail(int id=0)
		{
			List<ProductInfo> list = new List<ProductInfo>()
			{
				new ProductInfo(1,"Vip"),
				new ProductInfo(2,"C#"),
				new ProductInfo(3,"Mvc"),

			};
			if (id > 0)
			{
				var product = list.FirstOrDefault(p => p.id == id);
				return Ok(product);
			}
			return NotFound();
		}

		[Route("Index")]
		public IActionResult Index() {
			return Ok("属性路由");
		}
	}

	public record ProductInfo(int id,string productName);
}
